using System;
using System.Threading.Tasks;

namespace GomokuGame.AI
{
    /// <summary>
    /// AI难度等级枚举
    /// </summary>
    public enum AIDifficulty
    {
        Beginner = 1,    // 初级：随机落子
        Intermediate = 2, // 中级：基础策略
        Advanced = 3,     // 高级：Alpha-Beta剪枝
        Expert = 4        // 专家：深度学习模型
    }

    /// <summary>
    /// AI算法接口
    /// </summary>
    public interface IAIAlgorithm
    {
        /// <summary>
        /// AI难度等级
        /// </summary>
        AIDifficulty Difficulty { get; }

        /// <summary>
        /// AI名称
        /// </summary>
        string Name { get; }

        /// <summary>
        /// 计算下一步移动
        /// </summary>
        /// <param name="board">当前棋盘状态</param>
        /// <param name="currentPlayer">当前玩家</param>
        /// <param name="maxThinkingTime">最大思考时间（毫秒）</param>
        /// <returns>下一步移动位置</returns>
        Task<Move> CalculateNextMoveAsync(PieceType[,] board, PieceType currentPlayer, int maxThinkingTime = 5000);

        /// <summary>
        /// 计算下一步移动（同步版本）
        /// </summary>
        /// <param name="board">当前棋盘状态</param>
        /// <param name="currentPlayer">当前玩家</param>
        /// <param name="maxThinkingTime">最大思考时间（毫秒）</param>
        /// <returns>下一步移动位置</returns>
        Move CalculateNextMove(PieceType[,] board, PieceType currentPlayer, int maxThinkingTime = 5000);

        /// <summary>
        /// 获取AI思考进度（0-100）
        /// </summary>
        /// <returns>思考进度百分比</returns>
        int GetThinkingProgress();

        /// <summary>
        /// 重置AI状态
        /// </summary>
        void Reset();
    }

    /// <summary>
    /// AI移动结果
    /// </summary>
    public class Move
    {
        public int Row { get; set; }
        public int Col { get; set; }
        public PieceType PieceType { get; set; }
        public double Score { get; set; } // AI评估的分数
        public int ThinkingTime { get; set; } // 思考时间（毫秒）

        public Move(int row, int col, PieceType pieceType, double score = 0, int thinkingTime = 0)
        {
            Row = row;
            Col = col;
            PieceType = pieceType;
            Score = score;
            ThinkingTime = thinkingTime;
        }
    }
} 